<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>分表工具</title>
  	<link rel="stylesheet" href="index.css"/>
	<link rel="stylesheet" href="index.css"/>
	<script src="table/yiqbTable.js"></script>
	<script src="table/yccw1Table.js"></script>
	<script src="table/yccw2Table.js"></script>
	<script src="table/yiqcTable.js"></script>
	<script src="table/index.js"></script>
  </head>
  <body>
  	<div class="top">
		<div class="top-item"><input id="sqlInput" name="sqlInput" placeholder="分表SQL"/></div>
		<div class="top-item">
			<select id="sqlGroup" placeholder="分表归属">
				<option value="yiqb" selected>易企报</option>
				<option value="yiqc">易企财</option>
				<option value="yccw1">有成财务(报销)</option>
				<option value="yccw2">有成财务(财务)</option>
			</select>
		</div>
		<div class="top-item"><input id="corpId" placeholder="企业编号：具体识别编号" /></div>
		<div class="top-item"><input id="corpName" placeholder="企业名称：历史记录中备忘" /></div>
		<div class="top-item"><input id="fix" placeholder="指定分表数" /></div>
		<div class="top-item"><input id="tableName" placeholder="表名" /></div>
		<div class="top-item"><button id="button" >识别</button></div>
	</div>
	<div class="middle">
		<div class="middle-left">
			<textarea id="sql" placeholder="分表SQL解析结果"></textarea>
		</div>
		<div class="middle-right">
			<div id="content">
			</div>
		</div>
	</div>
	<div class="bottom">
		<div class="bottom-box">
			<div class="history-label"> 历史使用 <span class="clear-st" onclick="clearHistory()">清空历史</span></div>
			<div id="history" style="width: 90%;">
			</div>
		</div>
		<div class="bottom-box">
			<div> 有成报销表 </div>
			<div id="yiqbTableInfo" class="table-fix">
			</div>
			<div> 有成财务表(报销) </div>
			<div id="yccw1TableInfo" class="table-fix">
			</div>
		</div>
		<div class="bottom-box">
			<div> 易企财表 </div>
			<div id="yiqcTableInfo" class="table-fix">
			</div>
			<div> 有成财务表(财务) </div>
			<div id="yccw2TableInfo" class="table-fix">
			</div>
		</div>
	</div>
  	<div class="raycloud">
		<div class="raycloud-tab">
			<div class="raycloud-tab-item" data-id="FBXT" onclick="raycloudOnclick(event)">发布系统</div>
			<div class="raycloud-tab-item" data-id="YWXT" onclick="raycloudOnclick(event)">运维系统</div>
			<div class="raycloud-tab-item" data-id="SJKXT" onclick="raycloudOnclick(event)">数据库系统</div>
			<div class="raycloud-tab-item" data-id="FWQXX" onclick="raycloudOnclick(event)">服务器信息</div>
		</div>
		<div class="raycloud-content">
			<div id="FBXT" style="display: none;">
				<iframe width="100%" height="855px" src="https://sync.superboss.cc/index.xhtml#/welcome"></iframe>
			</div>
			<div id="YWXT" style="display: none;">
				<iframe width="100%" height="855px" src="http://task.superboss.cc/index.jsp#/task/list"></iframe>
			</div>
			<div id="SJKXT" style="display: none;">
				<iframe width="100%" height="855px" src="https://sql.superboss.cc/new_index.jsp?raycloud_sso_token=07a980b2-fa16-4861-933b-50511d4788c8#/sql/main"></iframe>
			</div>
			<div id="FWQXX" style="display: none;">
				<iframe width="100%" height="855px" src="https://www.wolai.com/gongli/fF3ZUSsB1FYb7RV7BPeWPg"></iframe>
			</div>
		</div>
	</div>
  </body>
  <script>
	  window.corpIdEl = document.getElementById('corpId');
	  window.corpNameEl = document.getElementById('corpName');
	  window.sqlInputEl = document.getElementById('sqlInput');
	  window.sqlGroupEl = document.getElementById('sqlGroup');
	  window.fixEl = document.getElementById('fix');
	  window.buttonEl = document.getElementById('button');
	  window.contentEl = document.getElementById('content');
	  window.historyEl = document.getElementById('history');
	  window.sqlEl = document.getElementById('sql');
	  window.tableNameEl = document.getElementById('tableName');
	  window.yccw1TableInfoEl = document.getElementById('yccw1TableInfo');
	  window.yiqbTableInfoEl = document.getElementById('yiqbTableInfo');
	  window.yccw2TableInfoEl = document.getElementById('yccw2TableInfo');
	  window.yiqcTableInfoEl = document.getElementById('yiqcTableInfo');
	  function hashCode(str){
		  var hash = 0;
		  if (str.length == 0) return hash;
		  for (i = 0; i < str.length; i++) {
			  char = str.charCodeAt(i);
			  hash = ((hash<<5)-hash)+char;
			  hash = hash & hash; // Convert to 32bit integer
		  }
		  return hash;
	  }

	  function onKeyEvent(event){
		  if(event.keyCode === 13){
			  onOp()
		  }
	  }

	  corpIdEl.onkeyup = onKeyEvent
	  corpNameEl.onkeyup = onKeyEvent
	  fixEl.onkeyup = onKeyEvent
	  tableNameEl.onkeyup = onKeyEvent
	  sqlInputEl.onkeyup = onKeyEvent
	  buttonEl.onclick = onOp
	  window.hashCode = hashCode


	  //设置自定义过期时间cookie
	  function setCookie(name,value,time){
		  var exp = new Date();
		  exp.setTime(exp.getTime() + time);
		  document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString() + ";path=/";
	  }
	  //读取cookies
	  function getCookie(name){
		  var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); //正则匹配
		  if(arr=document.cookie.match(reg)){
			  return unescape(arr[2]);
		  }
		  else{
			  return null;
		  }
	  }
	  //删除cookies
	  function delCookie(name){
		  var exp = new Date();
		  exp.setTime(exp.getTime() - 1);
		  var cval=getCookie(name);
		  if(cval!=null){
			  document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString() + ";path=/"
		  }
	  }

	  function onOp() {
		  addHistory(corpIdEl.value, corpNameEl.value)
		  showHistory();
		  reander(corpIdEl.value ? Math.abs(window.hashCode(corpIdEl.value)) : 0);
	  }

	  function raycloudOnclick(event){
		  for (const el of document.getElementsByClassName('raycloud-tab-item')) {
			  el.className = 'raycloud-tab-item';
			  document.getElementById(el.dataset.id).style.display = 'none';
		  }
		  event.target.className = 'raycloud-tab-item active'
		  document.getElementById(event.target.dataset.id).style.display = '';
	  }
  </script>
</html>
